﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SortLINQandLambdaExpression
{
    class SortLINQandLambdaExpression
    {
        static void Main(string[] args)
        {
            var students = new[] 
            {
                new { name = "Ivan", sirname = "Ivanov"},
                new { name = "Dragan", sirname = "Todorov"},
                new { name = "Stoian", sirname = "Ivanov"},
                new { name = "Tanq", sirname = "Borisova"},
                new { name = "Tonka", sirname = "Boncheva"},
                new { name = "Antonii", sirname = "Sotirov"},
                new { name = "Antonii", sirname = "Angelov"},
                new { name = "Antonii", sirname = "Botirov"},
                new { name = "Bai", sirname = "Ivan"},
            };
            
            var sortedStudets = students.OrderBy( stud => stud.name).ThenByDescending( stud => stud.sirname);
            foreach (var student in sortedStudets)
            {
                Console.WriteLine(student.name + " " + student.sirname);
            }

            var sortedStudentsLINQ =
                from student in students 
                orderby student.sirname descending
                orderby student.name
                select student.name + " " + student.sirname;

            Console.WriteLine();
            foreach (var student in sortedStudentsLINQ)
            {
                Console.WriteLine(student);
            }
                
        }
    }
}
